package com.util.description;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yutianhong
 * @version 1.0
 * @since 2024/01/01 23:17
 */
public
interface ParameterizedTypeDesc extends TypeDesc {
    static ParameterizedTypeDesc of(String className, List<TypeDesc> typeArguments) {
        return new DefaultParameterizedTypeDesc(className, typeArguments);
    }

    @Override
    default boolean isParameterized() {
        return true;
    }

    List<TypeDesc> getTypeArguments();

}
class DefaultParameterizedTypeDesc implements ParameterizedTypeDesc {
    String className;
    List<TypeDesc> typeArguments;

    public DefaultParameterizedTypeDesc(String className, List<TypeDesc> typeArguments) {
        this.className = className;
        this.typeArguments = new ArrayList<>(typeArguments);
    }

    @Override
    public String className() {
        return className;
    }

    @Override
    public List<TypeDesc> getTypeArguments() {
        return typeArguments;
    }
}